package com.company;

import org.junit.Assert;
import org.junit.Test;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class NGuessNumberTest {


    @Test
    public void generateAnswerTest() {
        List<Integer> answerList = NGuessNumber.generateAnswer();
        Set<Integer> answerSet = new HashSet<>();
        boolean flag = false;
        for (Integer item : answerList) {
            answerSet.add(item);
            flag = NGuessNumber.isBetween0And9(item);
        }
        Assert.assertEquals("检查答案数字数量是否为4", 4, answerList.size());
        Assert.assertEquals("检查答案数字是否有重复,通过测试表示无重复", 4, answerSet.size());
        Assert.assertEquals("检查答案数字是否都在[0-9]之间", true, flag);
    }

    @Test
    public void getPlayerInputTest() {
        List<Integer> playerInput = NGuessNumber.getPlayerInput();
        Assert.assertEquals("检查玩家猜测的数字数量是否为4。", 4, playerInput.size());
    }
}
